#include <iostream>
using namespace std;
#include "MyVector.cpp"
#include "Teacher.h"

//泛型编程最大的好处就是数据类型与算法的分离
//例如 数据类型与数组算法的分离
int main01(int argc, char const *argv[]){
        MyVector<int>  myv1(10);
        for (int i = 0; i < myv1.getLen(); i++){
                myv1[i] = i+1;
                cout<<myv1[i]<<" ";
        }

        cout<<endl;

        MyVector<int> myv2 = myv1;
        for (int i = 0; i < myv2.getLen(); i++){
                cout<<myv2[i]<<" ";
        }
        cout<<endl;

        cout<<myv2<<endl;    
        return 0;
}

int main02(int argc, char const *argv[]){
        MyVector<char> myv1(10);
        myv1[0] = 'a';
        myv1[1] = 'b';
        myv1[2] = 'c';
        myv1[3] = 'd';
        cout<<myv1<<endl;
        return 0;
}

//如果泛型的数据类型里面某个属性是指针,那么存在深copy和浅copy的问题
//需要在数据类型里面实现
        //赋值构造函数(拷贝构造函数)
        //重载=号操作符
        //重载<<号操作符
int main03(int argc, char const *argv[]){
        Teacher t1("t1",31), t2("t2",32), t3("t3",33), t4("t4",34);
        
        MyVector<Teacher> tarr(4);

        tarr[0] = t1;
        tarr[1] = t2;
        tarr[2] = t3;
        tarr[3] = t4;

        cout<<tarr<<endl;

        return 0;
}

int main(int argc, char const *argv[])
{
        Teacher t1("t1",31), t2("t2",32), t3("t3",33), t4("t4",34);
        
        MyVector<Teacher *> tarr(4);
        tarr[0] = &t1;
        tarr[1] = &t2;
        tarr[2] = &t3;
        tarr[3] = &t4;

        for (int i = 0; i < tarr.getLen(); i++)
        {
                Teacher *tmp = tarr[i];
                
        }
        

        cout<<tarr;

        return 0;
}
